# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

_hkgname=timezone-olson
pkgname=haskell-${_hkgname}
pkgver=0.2.1
pkgrel=1
pkgdesc='Pure Haskell parser and renderer for binary Olson timezone files'
url='http://projects.haskell.org/time-ng/'
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-extensible-exceptions' 'haskell-timezone-series')
makedepends=('ghc')
source=(https://hackage.haskell.org/package/${_hkgname}-${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha256sums=('ac551c2765dff82073958d19d4548b0c5ad88a83d2a5a7859c51a8af0741c581')
sha512sums=('243ea612a4af206d629ba1f3b3b01b1470e849a5ce50c2c189da246eac6f043ac7fb4f039df94053c7a1da9d2aeb347e510560fd0fa590264a5e3897a8dd1300')

build() {
  cd ${_hkgname}-${pkgver}
    runhaskell Setup configure -O \
      --enable-shared \
      --enable-executable-dynamic \
      --disable-library-vanilla \
      --prefix=/usr \
      --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
      --dynlibdir=/usr/lib \
      --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
      --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \
      --ghc-option='-pie'
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup haddock
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
  cd ${_hkgname}-${pkgver}
  runhaskell Setup test --show-details=direct
}

package() {
  cd ${_hkgname}-${pkgver}
  install -Dm 744 register.sh "${pkgdir}/usr/share/haskell/register/${pkgname}.sh"
  install -Dm 744 unregister.sh "${pkgdir}/usr/share/haskell/unregister/${pkgname}.sh"
  install -dm 755 "${pkgdir}/usr/share/doc/ghc/html/libraries"
  runhaskell Setup copy --destdir="$pkgdir"

  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  ln -s /usr/share/doc/${pkgname}/html "${pkgdir}/usr/share/doc/ghc/html/libraries/${_hkgname}"
}

# vim: ts=2 sw=2 et:
